218
a:4:{s:8:"template";a:2:{s:55:"E:/xampp/htdocs/rbac/Admin/Tpl/Authority/addAccess.html";b:1;s:29:"../Common/head_authority.html";b:1;}s:9:"timestamp";i:1522127050;s:7:"expires";i:1522127053;s:13:"cache_serials";a:0:{}}<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>权限</title>
    <link href="http://localhost/rbac/Admin/Tpl/Public/css/bootstrap.min.css" type="text/css" rel="stylesheet"/>
    <link href="http://localhost/rbac/Admin/Tpl/Public/css/admin-authority.css" type="text/css" rel="stylesheet"/>
    <script src="http://localhost/rbac/Admin/Tpl/Public/js/jquery-3.2.1.min.js"></script>
    <script src="http://localhost/rbac/Admin/Tpl/Public/js/bootstrap.min.js"></script>
</head><body>
<div class="container-fluid">
    <div class="row" style="margin: 20px 0px;">
        <b>添加权限</b>
        <a href="javascript:history.back();" style="float: right;">返回</a>
    </div>
    <form action="#" method="post">
        <div class="row" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>菜单等级</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <select id="level" name="level" class="form-control">
                    <option value="0">一级菜单</option>
                    <option value="1">二级菜单</option>
                    <option value="2">三级菜单</option>
                </select>
            </div>
        </div>
        <div class="row" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>权限标题</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <input type="text" name="title" class="form-control"/>
            </div>
        </div>
        <div class="row" id="parent_box" style="height: 35px;line-height: 35px;margin-top: 15px;display: none;" disabled>
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>父级菜单</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <select id="parent_id" name="parent_id" class="form-control">
                </select>
            </div>
        </div>
        <div class="row" id="control_box" style="height: 35px;line-height: 35px;margin-top: 15px;display: none;" disabled>
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>控制器名</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <input type="text" name="control" class="form-control"/>
            </div>
        </div>
        <div class="row" id="method_box" style="height: 35px;line-height: 35px;margin-top: 15px;display: none;" disabled>
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>方法名</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <input type="text" name="method" class="form-control"/>
            </div>
        </div>
        <div class="row" id="icon_box" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>图标类</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <input type="text" name="icon_class" class="form-control"/>
            </div>
        </div>
        <div class="row" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <button type="submit" class="btn btn-primary pull-right">确定</button>
            </div>
        </div>
    </form>
</body>

<script>
    $(document).ready(function(){
        $("#level").change(function(){
            var level = $("#level option:selected").val();
            if(level == 1 || level == 2){
                $("#icon_box").css("display","none");
                $("#icon_box").attr("disabled");
                $("#parent_box,#control_box,#method_box").removeAttr("disabled");
                $("#parent_box,#control_box,#method_box").css("display","block");
                $.ajax({
                    type:'post',
                    url:'./admin.php?c=Authority&m=getParentsIdByLevel',
                    data:{level:level},
                    dataType:'json',
                    success:function(data){
                        var html = "";
                        for(var i=0; i<data.length; i++){
                            html += " <option value='"+data[i].id+"'>"+data[i].title+"</option>";
                        }
                        $("#parent_id").html(html);
                    }
                })
            }
            if(level == 0){
                $("#icon_box").css("display","block");
                $("#icon_box").removeAttr("disabled");
                $("#parent_box,#control_box,#method_box").attr("disabled");
                $("#parent_box,#control_box,#method_box").css("display","none");
            }
        })
    })
</script>

</html>